package statemachines;

import java.util.HashMap;

import modelewithstatemachine.TaxiWithStateMachine;


// Juste pour voir si ça marche, ne pas faire attention à ce package.

public class StateMachine {
	private HashMap<String, State> statesMap;
	private State currentState;
	
	public StateMachine() {
		statesMap = new HashMap<String, State>();
		currentState = null;
	}
	
	public StateMachine(State startState) {
		statesMap = new HashMap<String, State>();
		addState(startState);
		currentState = startState;
	}
	
	public void addState(State state) {
		statesMap.put(state.getName(), state);
		state.setParentStateMachine(this);
	}
	
	public void setStartState(String stateName) {
		goTo(stateName);
	}
	
	public void goTo(String stateName) {
		currentState = statesMap.get(stateName);
	}
	
	public void playNextStep() {
		currentState.playNextStep();
	}
}
